// pages/detail/detail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    videoInfo:null,
    otherList:[],
    commentData:null,
    tt:"ssssss"
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      // console.log(options)
      let videoId=options.id;
      this.getCurrentVideo(videoId);
      this.getOtherList(videoId);
      this.getCommentList(videoId);
      // this.getTt();
  },
getTt(){
  this.setData({
    tt:"eeeee"
  })
},
  getCurrentVideo(videoId){
    let that = this;
    wx.request({
      url: 'https://www.fastmock.site/mock/be38daec3e9171cdb01c93689baff38b/bilibili/videoDetail?id='+videoId,
      success(res){
        console.log(res);
        if(res.data.code===0){
          that.setData({
            videoInfo:res.data.data.videoInfo
          })
        }
      }
    })
  },
  // 获取推荐视频
  getOtherList(videoId){
    let that = this;
    wx.request({
      url: 'https://www.fastmock.site/mock/be38daec3e9171cdb01c93689baff38b/bilibili/otherList?id='+videoId,
      success(res){
        // console.log(res)
        if(res.data.code===0){
          that.setData({otherList:res.data.data.otherList})
          
        }
        // console.log(res.data.data.otherList[0].author)
      }
    })
  },

  // 获取评论数据
  getCommentList(videoId){
    let that = this;
    wx.request({
      url: 'https://www.fastmock.site/mock/be38daec3e9171cdb01c93689baff38b/bilibili/commentData?id='+videoId,
      success(res){
        // console.log(res)
        if(res.data.code===0){
          that.setData({
           commentData:res.data.data.commentData
          })
        }
      }
    })
  },

  

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})